//Basic Camera Class

#ifndef ICAMERA_H
#define ICAMERA_H

#include "D3DObj.h"
#include "Vec3.h"
#include "Matrix4x4.h"

class ICamera
{
public:
	ICamera();

	void SetCameraPos(const Vec3& Pos);
	void SetCameraTarget(const Vec3& Target);
	void SetSpeed(float s);
	void SetRotation(float rotationY){m_AngleY = rotationY ;}

	void LookAt(Vec3& pos, Vec3& target, Vec3& up);
	
	Vec3& GetCameraPos();
	
	void BuildProjectionMatrix(float fov, float aspect, float nearZ, float farZ);	
	
	void SetViewMatrix(const Matrix4x4& View);
	void SetViewMatrixOrig(const Matrix4x4& View);

	const Matrix4x4& GetViewMatrix() const;
	const Matrix4x4& GetProjectionMatrix() const;
	const Matrix4x4& GetViewProjMatrix();
	const Matrix4x4& GetWorldMatrix() const;

	const Vec3& GetRight() const;
	const Vec3& GetUp() const;
	const Vec3& GetLook()const;

	virtual void Update() = 0;
	virtual void Draw() = 0;

	Matrix4x4 CalcViewMatrix(Vec3& pos, Vec3& target, Vec3& up);

	void BuildReflectionViewMatrix();
	Matrix4x4 GetReflectionViewMatrix();

	// Box coordinates should be relative to world space.
	bool isVisible(Vec3 pos);
	bool isVisible(Vec3 pos, const float radius);

	virtual void OnActive() {};
	virtual void OnDeActive() {};

	virtual void Load() {};

protected:
	void BuildView();

protected:
	
	Matrix4x4 m_View;
	Matrix4x4 m_Proj;
	Matrix4x4 m_ViewProj;
	Matrix4x4 m_WorldMatrix;
	Matrix4x4 m_ReflectionViewMatrix;

	// Relative to world space.
	Vec3 m_PosW;

	Vec3 m_RightW;
	Vec3 m_UpW;
	Vec3 m_LookW;

	float m_Speed;

	float m_AngleY;
	//Frustum m_Frustum;

	//float m_PosX;
	//float m_PosY;
	float m_Pitch;
	
	float m_Fov; 
	float m_Aspect; 
	float m_Near; 
	float m_Far;

	bool UpdateFrustum;
	bool FrustumDraw;
};

#endif